package com.atguigu.controller;

import com.atguigu.bean.User;
import com.atguigu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;


/**
 * UserController属于web环境
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/addUser")
	@ResponseBody
    public String addUser(@RequestBody User user, HttpServletRequest request) throws Exception {
		int count = userService.addUser(user);
        if (count>0){
        	return "success";
		}else {
        	return "fail";
		}
    }

}
